package com.iotek.bookstore.web.controlle;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/codeServlet")
public class VCodeJudgeServlet extends CommonServlet {
    @Override
    public void doInsert(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    @Override
    public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    @Override
    public void doUpdate(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    @Override
    public void doQuery(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String vCode1=(String)req.getSession(false).getAttribute("vcode");
        String vCode2=req.getParameter("vcoade");
        if(vCode2.equals(vCode1)){
            //1为验证码正确
            resp.getWriter().write("1");
            System.out.println("验证码正确");
        }else {
            //2为验证码错误
            resp.getWriter().write("2");
            System.out.println("验证码错误");
        }
    }
}
